package com.example.springboot.pojo;

import lombok.Data;

@Data
public class Result<T> {

    private boolean success;
    private Integer code;
    private String msg;
    private T data;


    private Result(boolean success, String msg) {
        this.success = success;
        this.msg = msg;
    }


    private Result(boolean success, T data) {
        this.success = success;
        this.data = data;
    }


    public static <T> Result<T> success(T data) {
        return new Result<T>(true, data);

    }

    public static <T> Result<T> successMsg(String msg) {
        return new Result<T>(true, msg);

    }

    public static <T> Result<T> error(String msg) {
        return new Result<T>(false, msg);

    }

}
